build(docker): Add Linux LSP support by fixing compile_commands.json paths#2303
Open
abhatem wants to merge 1 commit intoTheSuperHackers:mainfrom
Open
build(docker): Add Linux LSP support by fixing compile_commands.json paths#2303abhatem wants to merge 1 commit intoTheSuperHackers:mainfrom
abhatem wants to merge 1 commit intoTheSuperHackers:mainfrom
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| scripts/docker-build.sh | Added fix_compile_commands() function to automatically fix compile_commands.json paths after build, with proper error handling |
| scripts/fix_compile_commands.py | New Python script to transform Docker container paths to host paths for LSP support; logic works but replacement order could be more robust |
Sequence Diagram
sequenceDiagram
participant User
participant docker-build.sh
participant Docker Container
participant fix_compile_commands.py
participant Host Filesystem
User->>docker-build.sh: Execute build script
docker-build.sh->>Docker Container: Run build in container
Docker Container->>Host Filesystem: Generate compile_commands.json<br/>(with container paths /build/cnc)
docker-build.sh->>fix_compile_commands.py: Run post-build fix script
fix_compile_commands.py->>Host Filesystem: Read compile_commands.json<br/>from build/docker/
fix_compile_commands.py->>fix_compile_commands.py: Transform paths:<br/>- /build/cnc → host path<br/>- backslashes → forward slashes<br/>- strip Wine drive letters
fix_compile_commands.py->>Host Filesystem: Write fixed compile_commands.json<br/>to project root
docker-build.sh->>User: Build complete, LSP ready
Last reviewed commit: db5cdaf
926ec90 to
2b2e052
Compare
2b2e052 to
1aacdc5
Compare
….json Added scripts/fix_compile_commands.py to rewrite container paths to host paths and updated scripts/docker-build.sh to automatically run it after build.
1aacdc5 to
db5cdaf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the development experience for Linux contributors by making the
compile_commands.jsongenerated inside the Docker container usable on the host machine.Problem
Currently, when building with
docker-build.sh, the generatedcompile_commands.jsoncontains:/build/cnc/...instead of the host's workspace path.\which confuse Linux LSP servers (like clangd/ccls).Z:references from Wine.This causes "Go to Definition" and other LSP features to fail in Linux editors (VS Code, Emacs, Neovim) because they cannot locate the source files.
Solution
scripts/fix_compile_commands.py: A Python script that:scripts/docker-build.sh: Automatically runs the fix script after a successful build ifpython3is detected.Testing
docker-build.shstill compiles the game successfully.compile_commands.jsonis generated and paths are correctly mapped to the host.Notes
scripts/fix_compile_commands.pywas mostly AI generated but human verified and tested